<?php if (!defined('THINK_PATH')) exit(); /*a:5:{s:61:"E:\www\sunwm\web/../application/admin\view\service\index.html";i:1510646408;s:61:"E:\www\sunwm\web/../application/admin\view\public\header.html";i:1503189484;s:61:"E:\www\sunwm\web/../application/admin\view\public\seller.html";i:1508382600;s:60:"E:\www\sunwm\web/../application/admin\view\public\pages.html";i:1509260822;s:61:"E:\www\sunwm\web/../application/admin\view\public\footer.html";i:1512624954;}*/ ?>
﻿<!DOCTYPE html>
<html lang="zh-cn">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<title><?php echo config('sitename'); ?>-<?php echo lang('label')['Login_title']; ?></title>
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/public/css/pintuer.css" />
		<link rel="stylesheet" type="text/css" href="__ROOT__/static/admin/css/admin.css" />
		<script type="text/javascript" src="__ROOT__/static/public/js/jquery.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/js/pintuer.js"></script>
		<script type="text/javascript" src="__ROOT__/static/admin/js/admin.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/layer/layer.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/laydate/laydate.js"></script>
		<script type="text/javascript" src="__ROOT__/static/public/laytpl/laytpl.js"></script>
	</head>

	<body>
	<style>
		html { overflow-x:hidden; }
	</style>
<form method="post">
    <div class="panel admin-panel">
        <div class="panel-head">
            <strong><?php echo lang('currency')['list']; ?></strong>
            <a style="float: right;" href="<?php echo url('seller/index'); ?>?page=<?php echo input('get.page'); ?>"><< 返回</a>
        </div>
        <div class="padding border-bottom">
            <script>
                //city 参数和回调
                var uid = '<?php echo input("get.uid"); ?>';
                function select_uid() {
                    location.href="?uid="+uid;
                }
            </script>
            <input type="button" class="button button-small checkall" name="checkall" checkfor="id" value="<?php echo lang('currency')['all_select']; ?>"/>
            <a type="button" class="button button-small border-green" href="service/edit.html?uid=<?php echo input('get.uid'); ?>"/><?php echo lang('currency')['add']; ?></a>
            <a id="select_del" type="button" class="button button-small border-red" href="#"/><?php echo lang('currency')['del']; ?></a>
            选择商户：<select id="uid" name="uid" class="input input-auto">
	<option value="0">请选择</option>
</select>
<script id="uid_list_tpl" type="text/html">
	{{# for(var i = 0, len = d.data.length; i < len; i++){ }}
		<option {{# if(d.data[i].id==uid){}}selected{{#}}} value="{{ d.data[i].id }}">{{ d.data[i].name }}</option>
	{{# } }}
</script>
<script>
	var func = false;
	$('select').click(function(){
		func = true;
	});
	function start_seller(){
        $.getJSON('__URL__/get_seller', {}, function(res){
            if(res.data.length > 0 ){
                var tpl = $("#uid_list_tpl").html();
                laytpl(tpl).render(res, function(render){
                    $("#uid").html('<option value="0">请选择</option>'+render);
                });
            }
        });
	}
    start_seller();
	$('[name=uid]').change(function(){
		uid = $(this).val();
		if(func == true){
			select_uid();
		}
	});
</script>
            <a type="button" class="button button border-yellow search" href="#"/>标题<?php echo lang('label')['search']; ?></a>
        </div>
        <table class="table table-hover">
            <tr>
                <th width="50"><?php echo lang('label')['select']; ?></th>
                <th width="30">ID</th>
                <th width="100"><?php echo lang('label')['seller']; ?></th>
                <td width="50">展示图</td>
                <th width="120"><?php echo lang('label')['category']; ?></th>
                <th width="120"><?php echo lang('label')['title']; ?></th>
                <th width="50"><?php echo lang('label')['price']; ?></th>
                <th width="200">介绍</th>
                <!--<th width="100"><?php echo lang('label')['flag']; ?></th>-->
                <th width="100">商品类型</th>
                <th width="100"><?php echo lang('label')['status']; ?></th>
                <th width="100"><?php echo lang('label')['handle']; ?></th>
            </tr>
            <?php if(is_array($data) || $data instanceof \think\Collection || $data instanceof \think\Paginator): $i = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$service): $mod = ($i % 2 );++$i;?>
            <tr>
                <td style="line-height:40px">
                    <input type="checkbox" name="id" value="<?php echo $service['id']; ?>"/>
                </td>
                <td style="line-height:40px"><?php echo $service['id']; ?></td>
                <td style="line-height:40px"><?php echo get_name($service['uid']); ?></td>
                <td style="line-height:40px"><img src="<?php echo $service['image1']; ?>" width="40" height="40"/></td>
                <td style="line-height:40px"><?php echo get_catname($service['cate_id']); ?></td>
                <td style="line-height:40px"><?php echo $service['title']; ?></td>
                <td style="line-height:40px"><?php echo $service['price']; ?></td>
                <td style="line-height:40px"><?php echo $service['service']; ?></td>
                <td style="line-height:40px"><?php if($service['type'] == "0"): ?>商品外卖<?php else: ?>上门服务<?php endif; ?></td>
                <td style="line-height:40px"><?php if($service['status'] == 0): ?><span class="icon-times text-dot">下架</span><?php elseif($service['status'] == 1): ?><span class="icon-check text-sub">上架</span><?php endif; ?></td>
                <td style="line-height:40px">
                    <a class="button border-blue button-little" href="__URL__/edit.html?id=<?php echo $service['id']; ?>"><?php echo lang('currency')['edit']; ?></a>
                    <a class="button border-red button-little" href="__URL__/del.html?id=<?php echo $service['id']; ?>&page=<?php echo input('get.page'); ?>" onclick="if(confirm('<?php echo lang('currency')['del']; ?>?')){return true;}return false;"><?php echo lang('currency')['del']; ?></a>
                </td>
            </tr>
            <?php endforeach; endif; else: echo "" ;endif; ?>
        </table>
        <?php if($pages['pagetotal'] > 1): 
	$get_arr = request()->get();
	$parameters = '';
	if(count($get_arr) > 0){
		foreach($get_arr as $k => $v){
			if($k != 'page'){
				$parameters .= '&'.$k.'='.$v;
			}
		}
	}
	 ?>
	<div class="panel-foot text-center">
		<ul class="pagination green">
			<li><a href="#">共<?php echo $pages['total']; ?>条数据</a></li>
		</ul>
		<?php if($pages['page'] > 1): ?>
		<ul class="pagination">
			<li><a href="?page=<?php echo $pages['page']-1; ?><?php echo $parameters; ?>">上一页</a></li>
		</ul>
		<?php endif; ?>
		
		<ul class="pagination pagination-group">
		<?php $__FOR_START_25551__=1;$__FOR_END_25551__=$pages['pagetotal']+1;for($i=$__FOR_START_25551__;$i < $__FOR_END_25551__;$i+=1){ ?>
		<li><a href="?page=<?php echo $i; ?><?php echo $parameters; ?>" <?php if($pages['page']==$i): ?>class="active"<?php endif; ?>><?php echo $i; ?></a></li>
		<?php } ?>
		</ul>
		<?php if($pages['page'] < $pages['pagetotal']): ?>
		<ul class="pagination">
			<li><a href="?page=<?php echo $pages['page']+1; ?><?php echo $parameters; ?>">下一页</a></li>
		</ul>
		<?php endif; ?>
	</div>
<?php endif; ?>

    </div>
</form>
<script>
    layer.config({
        extend: 'extend/layer.ext.js'
    });
    $('#select_del').click(function () {
        var str = "";
        $("input:checkbox[name=id]:checked").each(function () {
            str += $(this).val() + ",";
        });
        if (str != '') {
            if (confirm("<?php echo lang('currency')['del']; ?>?"))
            {
                location.href = '<?php echo \think\Request::instance()->controller(); ?>/del.html?id=' + str;
            }
        }
    });
    $('.flag').click(function () {
        var id = $(this).attr("data-id");
        var oflag = $(this).attr("data-flag");
        var oflagtime = $(this).attr("data-flagtime");
        layer.open({
            title: "<?php echo lang('label')['flag']; ?>",
            content: "<div><?php echo lang('label')['flag']; ?>: <select id='flag'><option value='0'><?php echo lang('label')['flag_0']; ?></option><option value='1'><?php echo lang('label')['flag_1']; ?></option><option value='2'><?php echo lang('label')['flag_2']; ?></option><option value='3'><?php echo lang('label')['flag_3']; ?></option><option value='4'><?php echo lang('label')['flag_4']; ?></option></select></div><br/><div><?php echo lang('label')['time']; ?>: <input id='flagtime' type='date' value='" + oflagtime + "'/></div>",
            yes: function (layero, index) {
                var flag = $("#flag").val();
                var flagtime = $("#flagtime").val();
                if (flag == oflag && flagtime == oflagtime) {
                    layer.close(layero);
                } else {
                    if (flag > 0 && !flagtime) {
                        alert("<?php echo lang('label')['time']; ?><?php echo lang('currency')['required']; ?>");
                    } else {
                        if (flag <= 0) {
                            flagtime = "";
                        }
                        $.get("<?php echo url('admin/service/flag'); ?>?id=" + id + "&flag=" + flag + "&flagtime=" + flagtime, function (data) {
                            layer.msg(data.msg);
                            if (data.code == "success") {
                                location.reload();
                            }
                        });
                    }
                }
            },
            success: function (layero, index) {
                $("#flag").find("option[value='" + oflag + "']").attr("selected", true);
            }
        });
    });
    $('.search').click(function () {
        layer.prompt({title: '<?php echo lang('label')['service']; ?><?php echo lang('label')['search']; ?>'}, function (val) {
            location.href = "<?php echo url('/admin/service'); ?>?title=" + val;
        });
    });
</script>
<p class="text-center text-gray" style="margin-top:10px;"><a class="text-gray" target="_blank" href="http://www.wm0530.com">完美外卖系统 Power by 网络工厂</a></p>
</body>
<script>
$('.upload').on('click',function (){
		var id = $(this).attr('data-id');
		 upload(id);
	}
);
function upload(id){
	layer.open({
		type:2,
		title:false,
		area: ['70%', '90%'],
		offset: '5%',
		content: "<?php echo url('/admin/material'); ?>?id="+id
	});
}
</script>
</html>